<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp"%>
<script type="text/javascript">
	var partInstDataGrid;
	$(function() {
		partInstDataGrid = $('#partInstDataGrid')
				.datagrid(
						{
							url : '${path}/partInst/dataGrid',
							striped : true,
							rownumbers : true,
							pagination : true,
							singleSelect : true,
							idField : 'id',
							sortName : 'id',
							sortOrder : 'asc',
							pageSize : 20,
							pageList : [ 10, 20, 30, 40, 50, 100, 200, 300,
									400, 500 ],
							frozenColumns : [ [
								{
									width : '50',
									title : '编号',
									field : 'id',
									sortable : true
								},
									{
										width : '80',
										title : '参合证号',
										field : 'partNo',
										sortable : true
									},
									{
										width : '150',
										title : '家庭编号',
										field : 'familyNo',
										sortable : true
									},
									{
										width : '150',
										title : '身份证号',
										field : 'cardNo',
										sortable : true
									},
									
									{
										width : '50',
										title : '与户主关系',
										field : 'relaType',
										sortable : true
									},
									{
										width : '50',
										title : '姓名',
										field : 'name',
										sortable : true
									},
									{
										width : '50',
										title : '年齡',
										field : 'age',
										sortable : true
									},
									{
										width : '50',
										title : '性別',
										field : 'gender',
										sortable : true
									},
									{
										width : '50',
										title : '家庭住址',
										field : 'address',
										sortable : true
									},
									{
										width : '100',
										title : '联系方式',
										field : 'contact',
										sortable : true
									},
									{
										width : '100',
										title : '参合时间',
										field : 'partTime',
										sortable : true
									},									{
										width : '100',
										title : '发票号',
										field : 'invoNo',
										sortable : true
									},
									{
										field : 'action',
										title : '操作',
										width : 200,
										formatter : function(value, row, index) {
											var str = '';
											<shiro:hasPermission name="/partInst/edit">
											str += $
													.formatString(
															'<a href="javascript:void(0)" class="partInst-easyui-linkbutton-edit" data-options="plain:true,iconCls:\'fi-pencil icon-blue\'" onclick="partInstEditFun(\'{0}\');" >编辑</a>',
															row.id);
											</shiro:hasPermission>
											<shiro:hasPermission name="/partInst/delete">
											str += '&nbsp;&nbsp;|&nbsp;&nbsp;';
											str += $
													.formatString(
															'<a href="javascript:void(0)" class="partInst-easyui-linkbutton-del" data-options="plain:true,iconCls:\'fi-x icon-red\'" onclick="partInstDeleteFun(\'{0}\');" >删除</a>',
															row.id);
											</shiro:hasPermission>
											return str;
										}
									} ] ],
							onLoadSuccess : function(data) {
								$('.partInst-easyui-linkbutton-edit')
										.linkbutton({
											text : '编辑'
										});
								$('.partInst-easyui-linkbutton-del')
										.linkbutton({
											text : '删除'
										});
							},
							toolbar : '#partInstToolbar'
						});
	});

	/**
	 * 添加框
	 * @param url
	 */
	function partInstAddFun() {
		parent.$.modalDialog({
			title : '添加',
			width : 700,
			height : 600,
			href : '${path}/partInst/addPage',
			buttons : [ {
				text : '确定',
				handler : function() {
					parent.$.modalDialog.openner_dataGrid = partInstDataGrid;//因为添加成功之后，需要刷新这个treeGrid，所以先预定义好
					var f = parent.$.modalDialog.handler
							.find('#partInstAddForm');
					f.submit();
				}
			} ]
		});
	}

	/**
	 * 编辑
	 */
	function partInstEditFun(id) {
		if (id == undefined) {
			var rows = partInstDataGrid.datagrid('getSelections');
			id = rows[0].id;
		} else {
			partInstDataGrid.datagrid('unselectAll').datagrid('uncheckAll');
		}
		parent.$.modalDialog({
			title : '编辑',
			width : 700,
			height : 600,
			href : '${path}/partInst/editPage?id=' + id,
			buttons : [ {
				text : '确定',
				handler : function() {
					parent.$.modalDialog.openner_dataGrid = partInstDataGrid;//因为添加成功之后，需要刷新这个dataGrid，所以先预定义好
					var f = parent.$.modalDialog.handler
							.find('#partInstEditForm');
					f.submit();
				}
			} ]
		});
	}

	/**
	 * 删除
	 */
	function partInstDeleteFun(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = partInstDataGrid.datagrid('getSelections');
			id = rows[0].id;
		} else {//点击操作里面的删除图标会触发这个
			partInstDataGrid.datagrid('unselectAll').datagrid('uncheckAll');
		}
		parent.$.messager.confirm('询问', '您是否要删除当前角色？', function(b) {
			if (b) {
				progressLoad();
				$.post('${path}/partInst/delete', {
					id : id
				}, function(result) {
					if (result.success) {
						parent.$.messager.alert('提示', result.msg, 'info');
						partInstDataGrid.datagrid('reload');
					}
					progressClose();
				}, 'JSON');
			}
		});
	}

	/**
	 * 清除
	 */
	function partInstCleanFun() {
		$('#partInstSearchForm input').val('');
		partInstDataGrid.datagrid('load', {});
	}
	/**
	 * 搜索
	 */
	function partInstSearchFun() {
		partInstDataGrid.datagrid('load', $
				.serializeObject($('#partInstSearchForm')));
	}
</script>

<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'north',border:false"
		style="height: 30px; overflow: hidden; background-color: #fff">
		<form id="partInstSearchForm">
			<table>
				<tr>
					<th>请输入年度:</th>
					<td><input name="id" placeholder="搜索条件" /></td>
					<td><a href="javascript:void(0);" class="easyui-linkbutton"
						data-options="iconCls:'fi-magnifying-glass',plain:true"
						onclick="partInstSearchFun();">查询</a> <a
						href="javascript:void(0);" class="easyui-linkbutton"
						data-options="iconCls:'fi-x-circle',plain:true"
						onclick="partInstCleanFun();">清空</a></td>
				</tr>
			</table>
		</form>
	</div>

	<div data-options="region:'center',border:false">
		<table id="partInstDataGrid" data-options="fit:true,border:false"></table>
	</div>
</div>
<div id="partInstToolbar" style="display: none;">
	<shiro:hasPermission name="/partInst/add">
		<a onclick="partInstAddFun();" href="javascript:void(0);"
			class="easyui-linkbutton"
			data-options="plain:true,iconCls:'fi-page-add'">添加</a>
	</shiro:hasPermission>
</div>